/*
 * @Description: 待办数据模型
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2022-10-19 15:56:58
 * @LastEditTime: 2024-04-02 16:13:17
 * @FilePath: \cscec-pms-admin\src\views\matters\model.js
 */

import { getProjectTableDetails } from '@/api/technical/specificationList'
import { delByBusinessId } from '@/api/commons.js'
// 处理页面跳转配置
const actionMap = {
  // 学习教育
  1: (data, vm) => {
    vm.$router.push({
      path: '/partyMasses/partyManage/studyEduc/update',
      query: {
        pageType: 'look',
        messageType: 'resolve',
        id: data.businessId || '',
        messageId: data.id || '',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 参加考试(党群模块已经弃用不会发起考试)
  2: (data, vm) => {
    getSimpleExamPlanById({
      id: data.businessId
    })
      .then(({ data: { start, startTime } }) => {
        if (!start) {
          vm.$message.warning('考试开始时间:' + startTime)
        } else {
          vm.$router.push({
            path: '/partyMasses/partyManage/examinationPlan/paper',
            query: {
              id: data.receiverId,
              examPlanId: data.businessId,
              pageType: 'exam',
              resolveInfo: data.resolveInfo
            }
          })
        }
      })
      .catch((error) => {
        console.log(error)
      })
  },
  // 设计策划资料
  3: (data, vm) => {
    // vm.$router.push({
    //   path: '/project/design/planning/designPlanCollect'
    // })
    vm.$router.push({
      name: 'UpdateDesignPlanCollect',
      query: {
        pageType: 'look',
        id: data.businessId || ''
      }
    })
  },
  // 个人风险金补缴
  4: (data, vm) => {
    vm.$router.push({
      name: 'UpdatePersonalRiskPayment',
      query: {
        commissionType: 1,
        id: data.businessId || '',
        editModel: 0,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 项目规范清单作废
  5: (data, vm) => {
    vm.$refs.table.localLoading = true
    vm.dialogData.type = 5
    // vm.$refs.dialogForm.loading = true
    vm.dialogData.formList = vm.formList5
    vm.dialogData.title = '基础规范作废上报'
    vm.dialogData.resolveInfo = data.resolveInfo
    getProjectTableDetails({ id: data.businessId })
      .then((res) => {
        vm.visible = true
        vm.$refs.table.localLoading = false
        vm.dialogData.form = res.data
      })
      .catch((e) => {
        vm.$refs.dialogForm.loading = false
      })
  },
  // 基础规范过期
  6: (data, vm) => {
    vm.$refs.table.localLoading = true
    vm.dialogData.type = 6
    vm.dialogData.formList = vm.formList6
    vm.dialogData.title = '基础规范过期上报'
    vm.dialogData.resolveInfo = data.resolveInfo
    getProjectTableDetails({ id: data.businessId })
      .then((res) => {
        vm.visible = true
        vm.$refs.table.localLoading = false
        vm.dialogData.form = res.data
      })
      .catch((e) => {
        vm.$refs.dialogForm.loading = false
      })
  },
  // 施组方案联审
  110: (data, vm) => {
    vm.$router.push({
      path: '/technical/reviewMeeting/programReview/edit',
      query: {
        id: data.businessId || '',
        msgId: data.id || '',
        type: 'todo',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 危险源辨识会议及清单(项目生产经理)
  201: (data, vm) => {
    vm.$router.push({
      path: '/safetySupervision/hazardIdentification/safetyAddConferenceWaitDo',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 危险源辨识会议及清单(项目商务经理)
  202: (data, vm) => {
    vm.$router.push({
      path: '/safetySupervision/hazardIdentification/safetyAddConferenceWaitDo',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 危险源辨识会议及清单(项目安全总监)
  203: (data, vm) => {
    // console.log(data,'wwwwwwdatadatadatadata');
    // if (data) {
    //   data.taskPcUrl = '/safetySupervision/hazardIdentification/safetyAddConferenceWaitDo';
    // }
    // let routeData = vm.$router.resolve({
    //   path: data.taskPcUrl,
    //     query: {
    //     id: data.businessId || '',
    //     messageId: data.id || '',
    //     noticeType: data.noticeType,
    //     resolveInfo: data.resolveInfo
    //   }
    // })
    // console.log(routeData)
    // window.open(routeData.href, '_blank')
    vm.$router.push({
      path: '/safetySupervision/hazardIdentification/safetyAddConferenceWaitDo',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 危险源辨识会议及清单(项目总工)
  204: (data, vm) => {
    vm.$router.push({
      path: '/safetySupervision/hazardIdentification/safetyAddConferenceWaitDo',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 技术支持专家代办
  205: (data, vm) => {
    vm.$router.push({
      path: '/technical/expert/updateServiceSupport',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        type: 'todo',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 技术支持专家服务评分
  206: (data, vm) => {
    vm.$router.push({
      path: '/technical/expert/updateServiceSupport',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        type: 'todo',
        resolveInfo: data.resolveInfo
      }
    })
  },
  207: (data, vm) => {
    vm.$router.push({
      path: '/technical/dataManage/dailyDataManag/updateDailyDataManag',
      query: {
        id: data.businessId,
        editModel: 0,
        msgid: data.id,
        todoStatus: data.todoStatus,
        isSign: 1
      }
    })
  },
  //施工审批待办
  208: (data, vm) => {
    vm.$router.push({
      path: '/technical/ShiGroup/administrativeLedger/approve',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        editModel: 0,
        todoStatus: data.todoStatus,
        remark: data.remark
      }
    })
  },
  //设计变更
  209: (data, vm) => {
    let arr = data.remark?.split("岗位编号：");
    let str = arr[arr.length - 1];
    vm.$router.push({
      path: '/technical/designFM/updatedesignChanges',
      query: {
        id: data.businessId || '',
        soleId: str || '',
        messageId: data.id || '',
        editModel: 0,
        comment: false,
        resolveInfo: data.resolveInfo
      }
    })
  },
  //设计变更A1
  210: (data, vm) => {
    let arr = data.remark?.split("岗位编号：");
    let str = arr[arr.length - 1];
    vm.$router.push({
      path: '/project/design-changeView',
      query: {
        id: data.businessId || '',
        soleId: str || '',
        messageId: data.id || '',
        isEdit: 'view',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 质量责任制确认签名
  301: (data, vm) => {
    vm.$router.push({
      path: '/dutySystemSign',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // QC问题解决型课题资料评审
  302: (data, vm) => {
    vm.$router.push({
      path: '/scoringProcessing',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // QC创新型课题资料评审
  303: (data, vm) => {
    vm.$router.push({
      path: '/scoringProcessing',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 质量责任制确认签名(项目岗位质量责任目标协议书)
  304: (data, vm) => {
    vm.$router.push({
      path: '/dutySystemSign',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 分公司分包结算
  8: (data, vm) => {
    vm.$router.push({
      path: '/businessAffairs/updateSettlement',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 公司分包结算
  9: (data, vm) => {
    vm.$router.push({
      path: '/businessAffairs/updateSettlement',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 质量风险上报业务代办
  305: (data, vm) => {
    vm.$router.push({
      path: '/quality/riskIdentification/riskReportingAudit',
      query: {
        bussinessId: data.id || '',
        escalationId: data.businessId || '',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 质量风险上报业务代办（风险方案处理人）
  306: (data, vm) => {
    vm.$router.push({
      path: '/quality/riskIdentification/riskTrackingAudit',
      query: {
        bussinessId: data.id || '',
        escalationId: data.businessId || '',
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 设计问题上报
  307: (data, vm) => {
    vm.$router.push({
      path: '/design/designNeed/designIssueReportingBacklog',
      query: {
        id: data.id,
        bussinessId: data.businessId,
        editModel: 0,
        todoStatus: data.todoStatus
      }
    })
  },
  //项目管理策划
  401: (data, vm) => {
    // if (data) {
    //   data.taskPcUrl = '/project/approvalDetail';
    // }
    // let routeData = vm.$router.resolve({
    //   path: data.taskPcUrl,
    //   query: {
    //     id: data.businessId || '',
    //     messageId: data.id || '',
    //     noticeType: data.noticeType,
    //     resolveInfo: data.resolveInfo
    //   }
    // })
    // console.log(routeData)
    // window.open(routeData.href, '_blank')
    vm.$router.push({
      path: '/project/approvalDetail',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 竣工收尾工作计划
  402: (data, vm) => {
    vm.$router.push({
      path: '/construction/constructionSchedule/constructionCompleted/pending',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  //项目策划考核纠偏措施待办
  403: (data, vm) => {
    vm.$router.push({
      path: '/project/projectPlanningAssessment/assessment/edit',
      query: {
        type: 'handelMeasures',
        id: data.remark ? data.remark.split(':')[1] : '',
        messageId: data.id || '',
        businessId: data.businessId || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  //项目策划考核完成效果待办
  404: (data, vm) => {
    if (data.remark) {
      let obj = data.remark.split(';')
      let id = obj.length ? obj[0].split(':')[1] : ''
      let planExamineCheckItemsId = obj.length ? obj[1].split(':')[1] : ''
      vm.$router.push({
        path: '/project/projectPlanningAssessment/assessment/edit',
        query: {
          type: 'handelEffect',
          id: id,
          planExamineCheckItemsId: planExamineCheckItemsId,
          messageId: data.id || '',
          businessId: data.businessId || '',
          noticeType: data.noticeType,
          resolveInfo: data.resolveInfo
        }
      })
    }
  },
  // 质量整改通知单(后端已经删除数据，所以业务已办不会显示该模块数据，不需要修改resolveInfo相关配置)
  405: (data, vm) => {
    vm.$router.push({
      path: '/quality/rectificationNoticeAudit',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 质量整改通知单(后端已经删除数据，所以业务已办不会显示该模块数据，不需要修改resolveInfo相关配置)
  406: (data, vm) => {
    vm.$router.push({
      path: '/technical/technicalInspection/rectificationNoticeAudit',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 征询回复
  501: (data, vm) => {
    // path需要提取detailUrl中的参数
    vm.$router.push({
      path: data?.detailUrl?.split('?').length > 1 ? `/matters/list/solicitingOpinions?${data.detailUrl.split('?')[1]}` : '/matters/list/solicitingOpinions',
      query: {
        id: data.id || '',
        businessId: data.businessId || '',
        updateId: data.updateId || '',
        todoId: data.todoId,
        resolveInfo: data.resolveInfo,
        businessType: data.businessType,
        detailUrl: data.detailUrl,
        procInstId: data.procInstId,
        opinionsId: data.opinionsId
      }
    })
  },
  //推优(项目总工)业务待办
  602: (data, vm) => {
    vm.$router.push({
      path: '/technical/ShiGroup/Approval/EditFrom',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        type: 'allDisable',
        resolveInfo: data.resolveInfo
      }
    })
  },
  //分公司-技术质量部业务经理
  601: (data, vm) => {
    vm.$router.push({
      path: '/technical/ShiGroup/Approval/EditFrom',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        type: 'allDisable',
        resolveInfo: data.resolveInfo
      }
    })
  },
  //分包商月度考核分数确认
  701: (data, vm) => {
    vm.$router.push({
      path: '/month/examinationProcessing',
      query: {
        id: data.businessId || '',
        messageId: data.id || '',
        noticeType: data.noticeType,
        noticeContent: encodeURIComponent(data.noticeContent),
        resolveInfo: data.resolveInfo
      }
    })
  },
  // 调拨处理
  803: (data, vm) => {
    vm.$router.push({
      path: '/matters/allocate/allocateHandle',
      query: {
        businessId: data.businessId,
        id: data.id
      }
    })
  },
  // 调出处理
  801: (data, vm) => {
    vm.$router.push({
      path: '/matters/allocate/transferOutConfirm',
      query: {
        businessId: data.businessId,
        id: data.id
      }
    })
  },
  // 调入处理
  802: (data, vm) => {
    vm.$router.push({
      path: '/matters/allocate/transferInConfirm',
      query: {
        businessId: data.businessId,
        id: data.id
      }
    })
  },
  // 归还确认
  804: (data, vm) => {
    vm.$router.push({
      path: '/matters/todoList/affirmReturn',
      query: {
        businessId: data.businessId,
        messageId: data.id || '',
        id: data.id
      }
    })
  },
  // 商务成本计划管理
  901: (data, vm) => {
    delByBusinessId({
      businessId: data.businessId,
      noticeType: data.noticeType,
      status: '1'
    }).then(res => {
      vm.$refs.table.refresh()
      vm.$router.push({
        path: '/businessAffairs/businessCostPlanManagement/costPlanManagement/costPlan',
      })
    })
  },
}
export {
  actionMap
}